<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class SimCardRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $sim_card = $this->route('simCard');
        if ($sim_card) {
            return [
                'mobile' => 'required|unique:sim_cards|regex:/^1[3-8]\d{9}$/'
            ];
        } else {
            return [
                'startNum' => 'required|integer|min:1',
                'books' => 'required|integer|min:1',
                'pages' => 'required|integer|min:1',
                'boxes' => 'required|integer|min:1',
            ];
        }
    }
}
